import Vue from 'vue'
import Router from 'vue-router'
import HelloWorld from '@/components/HelloWorld'

Vue.use(Router)

export default new Router({
  mode: 'history',
  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    } else {
      return {
        x: 0,
        y: 0
      }
    }
  },

  routes: [
    // {
    //   path: '/',
    //   name: 'HelloWorld',
    //   component: HelloWorld
    // },
    {
      path: '/',
      component: () =>
        import('../components/page/home')
    },
    {
      path: '/user',

      component: () =>
        import('../components/page/user'),

      children: [
        // 我的账户
        {
          path: "/user/account",
          component: () =>
            import('../components/page/account'),
          children: [
            // 账户信息
            {
              path: "/user/account/account_msg",
              component: () =>
                import('../components/base/account_msg'),
            },
            {
              path: "/user/account/zz",
              component: () =>
                import('../components/base/zz'),
            },
            {
              path: "/user/account/bind_phone",
              component: () =>
                import('../components/base/bindphone'),
            },
            // 登录密码
            {
              path: "/user/account/login_pwd",
              component: () =>
                import('../components/base/login_pwd'),
            },
            {
              path: '/user/account',
              redirect: '/user/account/account_msg'
            }
          ]
        },
        // 充币提币
        {
          path: "/user/coin",
          component: () =>
            import('../components/page/coin'),
          children: [
            // 充币
            {
              path: "/user/coin/coin_in",
              component: () =>
                import('../components/base/coin_in'),
            },
            // 提币
            {
              path: "/user/coin/coin_out",
              component: () =>
                import('../components/base/coin_out'),
            },
            // 转币
            {
              path: "/user/coin/coin_turn",
              component: () =>
                  import('../components/base/coin_turn'),
            },
            {
              path: "/user/coin",
              redirect: '/user/coin/coin_in'
            }
          ]
        },
        {
          path: '/user',
          redirect: '/user/account'
        }
      ]
    },
    // 注册
    {
      path: "/register",
      component: () =>
        import('../components/page/register'),
    },

    {
      path: "/login",
      component: () =>
        import('../components/page/login'),
    },
    {
      path: "/repwd",
      component: () =>
        import('../components/page/repwd'),
    },
    {
      path: "/phonecode",
      component: () =>
        import('../components/page/phonecode'),
    },
    //路由重定向  路径不匹配时 跳转到首页
    {
      path: '*',
      redirect: '/'
    },
  ]
})
